package com.yc.snack.entity;

import com.yc.snack.util.StringUtil;

import java.util.Objects;

public class ProductInfo {
    private Integer gno;
    private String gname;
    private Integer tno;
    private Double price;
    private String intro;
    private Integer balance;
    private String pics;
    private String unit;
    private String qperied;
    private String weight;
    private String descr;
    private Integer status;

    private String pic; // 只有一张图片

    public String getPic() {
        return pic;
    }

    public void setPic(String pic) {
        this.pic = pic;
    }

    @Override
    public String toString() {
        return "ProductInfo{" +
                "gno=" + gno +
                ", gname='" + gname + '\'' +
                ", tno=" + tno +
                ", price=" + price +
                ", intro='" + intro + '\'' +
                ", balance=" + balance +
                ", pics='" + pics + '\'' +
                ", unit='" + unit + '\'' +
                ", qperied='" + qperied + '\'' +
                ", weight='" + weight + '\'' +
                ", descr='" + descr + '\'' +
                ", status=" + status +
                '}';
    }

    @Override
    public boolean equals(Object object) {
        if (this == object) return true;
        if (object == null || getClass() != object.getClass()) return false;
        ProductInfo that = (ProductInfo) object;
        return Objects.equals(gno, that.gno) &&
                Objects.equals(gname, that.gname) &&
                Objects.equals(tno, that.tno) &&
                Objects.equals(price, that.price) &&
                Objects.equals(intro, that.intro) &&
                Objects.equals(balance, that.balance) &&
                Objects.equals(pics, that.pics) &&
                Objects.equals(unit, that.unit) &&
                Objects.equals(qperied, that.qperied) &&
                Objects.equals(weight, that.weight) &&
                Objects.equals(descr, that.descr) &&
                Objects.equals(status, that.status);
    }

    @Override
    public int hashCode() {
        return Objects.hash(gno, gname, tno, price, intro, balance, pics, unit, qperied, weight, descr, status);
    }

    public Integer getGno() {
        return gno;
    }

    public void setGno(Integer gno) {
        this.gno = gno;
    }

    public String getGname() {
        return gname;
    }

    public void setGname(String gname) {
        this.gname = gname;
    }

    public Integer getTno() {
        return tno;
    }

    public void setTno(Integer tno) {
        this.tno = tno;
    }

    public Double getPrice() {
        return price;
    }

    public void setPrice(Double price) {
        this.price = price;
    }

    public String getIntro() {
        return intro;
    }

    public void setIntro(String intro) {
        this.intro = intro;
    }

    public Integer getBalance() {
        return balance;
    }

    public void setBalance(Integer balance) {
        this.balance = balance;
    }

    public String getPics() {
        return pics;
    }

    public void setPics(String pics) {
        this.pics = pics;
        if(!StringUtil.checkNull(pics)) { // 如果不为空则截取第一章图片放到pic属性中
            this.pic = pics.split(";")[0];
        }
    }

    public String getUnit() {
        return unit;
    }

    public void setUnit(String unit) {
        this.unit = unit;
    }

    public String getQperied() {
        return qperied;
    }

    public void setQperied(String qperied) {
        this.qperied = qperied;
    }

    public String getWeight() {
        return weight;
    }

    public void setWeight(String weight) {
        this.weight = weight;
    }

    public String getDescr() {
        return descr;
    }

    public void setDescr(String descr) {
        this.descr = descr;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }
}
